const app = getApp()
Page({
    data:{
        showView : true,
        name:null,
        passwd:null,
        message:null
    },
    getName(e){
        console.log(this.name);
        this.setData({
            name:e.detail.value
        });
        console.log(e.detail.value);
    },
    getPasser(e){
        this.setData({
            passwd:e.detail.value
            
        });
        console.log(e.detail.value);
    },
    sign(){
        var self = this
        if(self.data.name==null || self.data.passwd == null){
            wx.showModal({
              title:"账号密码不能为空"
            })
            return
          }
        wx.request({
          url: 'http://127.0.0.1:8080/sign',
          method:'POST',
          data:{
            name:this.data.name,
            passwd:this.data.passwd
          },
          success(res) {
            console.log(res.data)
              self.setData({
                message:res.data
              })
              console.log(self.data.message)
              if (self.data.message == "sign success"){
                wx.navigateTo({
                  url: '../index/index',
                })
              }
              else {
                wx.showModal({
                  title:"注册失败，请重新选择用户名"
                })
              }
          }
  
        })
  
    },
    return(){
        wx.navigateTo({
          url: '../index/index',
        })
      }
})
  